import { TableColumns } from '@pureadmin/table'

import { fenToYuan } from '@/utils'

interface TableColumnList extends Array<TableColumns> {}
const indexMethod = (index: number) => {
  return index + 1
}
export function useUser() {
  const columns: TableColumnList = [
    // {
    //   label: '勾选列', // 如果需要表格多选，此处label必须设置
    //   type: 'selection',
    //   minWidth: 55,
    //   fixed: 'left',
    //   reserveSelection: true // 数据刷新后保留选项
    // },
    {
      label: '排名',
      minWidth: 80,
      align: 'center',
      type: 'index',
      index: indexMethod
    },

    { prop: 'nodetName', label: '门店', minWidth: 150, align: 'left', slot: 'tenantName' },

    {
      prop: 'otherPrice',
      label: '实收业绩',
      minWidth: 100,
      align: 'center',
      sortable: true,
      slot: 'otherPrice',
      formatter({ otherPrice }) {
        return `${fenToYuan(otherPrice)}元`
      }
    },
    {
      prop: 'totalPrice',
      label: '销售业绩',
      minWidth: 100,
      align: 'center',
      sortable: true,
      slot: 'totalPrice',

      formatter({ totalPrice }) {
        return `${fenToYuan(totalPrice)}元`
      }
    },
    {
      prop: 'repayPrice',
      label: '还款业绩',
      minWidth: 100,
      align: 'center',
      sortable: true,
      slot: 'repayPrice',

      formatter({ repayPrice }) {
        return `${fenToYuan(repayPrice)}元`
      }
    },
    {
      prop: 'rechargePrice',
      label: '充值业绩',
      minWidth: 100,
      align: 'center',
      sortable: true,
      slot: 'rechargePrice',

      formatter({ rechargePrice }) {
        return `${fenToYuan(rechargePrice)}元`
      }
    },

    {
      prop: 'ppcPrice',
      label: '划卡业绩',
      minWidth: 100,
      align: 'center',
      sortable: true,
      slot: 'ppcPrice',

      formatter({ ppcPrice }) {
        return `${fenToYuan(ppcPrice)}元`
      }
    },
    {
      prop: 'performancePrice',
      label: '消耗业绩',
      minWidth: 100,
      align: 'center',
      sortable: true,
      slot: 'performancePrice',

      formatter({ performancePrice }) {
        return `${fenToYuan(performancePrice)}元`
      }
    },
    {
      prop: 'plossPrice',
      label: '盈亏平衡',
      minWidth: 100,
      align: 'center',
      sortable: true,

      formatter({ plossPrice }) {
        return `${fenToYuan(plossPrice)}`
      }
    },
    {
      prop: 'successRate',
      label: '完成率',
      minWidth: 100,
      align: 'center',
      sortable: true,

      formatter({ successRate }) {
        return `${successRate} %`
      }
    },

    {
      label: '操作',
      fixed: 'right',
      minWidth: 100,
      align: 'center',
      slot: 'operation'
    }
  ]

  return {
    columns
  }
}
